<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div class="parent">
      <div class="child">child</div>
      <div class="child1">child1</div>
    </div>
    <style>
      body {
        /* perspective: 300px; */
        height: 100vh;
      }
      .parent {
        width: 100px;
        height: 100px;
        /* background-color: black; */
        border: 1px solid red;
        margin: 300px;
        position: relative;

        perspective: 100px;
        /* 开启透视 */
        transform-style: preserve-3d;
        /* 子元素3d空间如何嵌套 */

        /* 都是写在 父级盒子 */
      }
      .child {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(255, 0, 255, 0.5);
        transition: all 1s;
        transform: rotateY(30deg);
      }
      .child1 {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 162, 255, 0.5);
        transition: all 1s;
      }

      .parent:hover .child1 {
        /* transform: rotateX(60deg); */
        transform: translateZ(-100px);
      }
    </style>
  </body>
</html>
